<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
          "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core">

<ui:composition template="base.xhtml">
	<ui:define name="content">
		<h:form>
			<h:dataTable value="#{venda.itens}" var="item"
				styleClass="table table-striped table-hover">
				<h:column>
					<h:outputText id="produtoOutputText" value="#{item.produto}" />
					<f:facet name="header">
						<h:outputText id="headerProduto" value="Produto" />
					</f:facet>
				</h:column>
				<h:column>
					<h:outputText id="pesoOutputText" value="#{item.produto.peso}" />
					<f:facet name="header">
						<h:outputText id="headerPeso" value="Peso (KG)" />
					</f:facet>
				</h:column>
				<h:column>
					<h:outputText id="quantidadeOutputText" value="#{item.quantidade}" />
					<f:facet name="header">
						<h:outputText id="headerQuantidade" value="Quantidade" />
					</f:facet>
				</h:column>
			</h:dataTable>

			<h:commandButton value="Calcular Frete"	action="#{venda.calculaFrete()}" styleClass="btn btn-primary">
				<f:ajax render="freteOutputText" />
			</h:commandButton>
			<h2><h:outputText id="freteOutputText" value="Valor do frete: #{venda.valorFrete}"/></h2>

			<h:commandButton value="Finaliza Venda" action="#{venda.finalizaVenda()}" styleClass="btn btn-danger"/>

		</h:form>
	</ui:define>
</ui:composition>
</html>